package com.xingkeduo.util.pojo.domain;

import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.xingkeduo.util.pojo.base.BaseJson;
import com.xingkeduo.util.pojo.enums.*;

/**
 * 招聘来源封装类
 * 
 * @author GJ
 * @time 2018年12月25日 下午1:45:17
 * @description
 */
public class EnumJTO extends BaseJson {
	public static ArrayNode toJsonForRecruitSource(RecruitSourceEnum[] recruitSources) throws Throwable {
		ArrayNode root = MAPPER.createArrayNode();

		for (int i = 0; i < recruitSources.length; i++) {
			ObjectNode node = MAPPER.createObjectNode();
			RecruitSourceEnum recruitSource = recruitSources[i];
			node.put(String.valueOf(recruitSource.getValue()), recruitSource.getDesc());
			root.add(node);
		}

		return root;
	}

	public static ArrayNode toJsonForDegree(DegreeEnum[] degrees) throws Throwable {
		ArrayNode root = MAPPER.createArrayNode();

		for (int i = 0; i < degrees.length; i++) {
			ObjectNode node = MAPPER.createObjectNode();
			DegreeEnum degree = degrees[i];
			node.put(String.valueOf(degree.getValue()), degree.getDesc());
			root.add(node);
		}

		return root;
	}

	public static ArrayNode toJsonForWorkYear(WorkYearEnum[] workYears) throws Throwable {
		ArrayNode root = MAPPER.createArrayNode();

		for (int i = 0; i < workYears.length; i++) {
			ObjectNode node = MAPPER.createObjectNode();
			WorkYearEnum workYear = workYears[i];
			node.put(String.valueOf(workYear.getValue()), workYear.getDesc());
			root.add(node);
		}

		return root;
	}

	public static ArrayNode toJsonForLeavingType(LeavingTypeEnum[] leavingTypes) throws Throwable {
		ArrayNode root = MAPPER.createArrayNode();

		for (int i = 0; i < leavingTypes.length; i++) {
			ObjectNode node = MAPPER.createObjectNode();
			LeavingTypeEnum leavingType = leavingTypes[i];
			node.put(String.valueOf(leavingType.getValue()), leavingType.getDesc());
			root.add(node);
		}

		return root;
	}

	public static ArrayNode toJsonBank(BankEnums[] bankEnums) throws Throwable {
		ArrayNode root = MAPPER.createArrayNode();

		for (int i = 0; i < bankEnums.length; i++) {
			ObjectNode node = MAPPER.createObjectNode();
			BankEnums bankType = bankEnums[i];
			node.put(String.valueOf(bankType.getValue()), bankType.getDesc());
			root.add(node);
		}

		return root;
	}
}
